﻿@{
    ViewBag.Title = "ChangePassword";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@model TamoCRM.Web.Mvc.Areas.Admin.Models.Users.ChangePasswordModel

<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed');
        } catch (e) { }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="/Home">Trang chủ</a>
        </li>

        <li>
            <a href="javascript:void(0);">Danh mục</a>
        </li>
        <li class="active">Người dùng</li>
    </ul>
</div>

<div class="page-content">
    <div class="page-header">
        <h1>Thay đổi mật khẩu</h1>
    </div>
    <!-- /.page-header -->

    <div class="row">
        <div class="form-group">
            <div class="col-sm-12" id="alert">
            </div>
        </div>
        <div class="col-xs-12">
            <div id="user-profile-1" class="user-profile row">
                <div class="col-xs-12 col-sm-3 center">
                    <div>
                        <span class="profile-picture">
                            <img id="avatar" class="editable img-responsive editable-click editable-empty" alt="Alex's Avatar" src="/Images/avatars/profile-pic.jpg" />
                        </span>
                        <div class="space-4"></div>
                        <div class="width-80 label label-info label-xlg arrowed-in arrowed-in-right">
                            <div class="inline position-relative">

                                @Model.UserInfo.FullName


                                <ul class="align-left dropdown-menu dropdown-caret dropdown-lighter">
                                    <li class="dropdown-header">Change Status </li>

                                    <li>
                                        <a href="#">
                                            <i class="icon-circle green"></i>
                                            &nbsp;
                                            <span class="green">Available</span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="#">
                                            <i class="icon-circle red"></i>
                                            &nbsp;
                                            <span class="red">Busy</span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="#">
                                            <i class="icon-circle grey"></i>
                                            &nbsp;
                                            <span class="grey">Invisible</span>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                @using (Html.BeginForm("ChangePassword", "User"))
                {
                    @Html.HiddenFor(x => x.UserInfo.UserName)
                    <div class="col-xs-12 col-sm-9">
                        <div class="profile-user-info profile-user-info-striped">
                            <div class="profile-info-row">
                                <div class="profile-info-name">Tên đăng nhập </div>

                                <div class="profile-info-value">
                                    @Model.UserInfo.UserName
                                    @Html.HiddenFor(x => x.UserInfo.UserName)
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name">Mật khẩu cũ</div>
                                <div class="profile-info-value">
                                    @Html.PasswordFor(x => x.OldPassword, new { @required = "required", error = "Mật khẩu không được rỗng" })
                                    @Html.ValidationMessageFor(x => x.OldPassword)
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name">Mật khẩu mới</div>
                                <div class="profile-info-value">
                                    @Html.PasswordFor(x => x.Password, new { @required = "required", error = "Mật khẩu không được rỗng" })
                                    @Html.ValidationMessageFor(x => x.Password)
                                </div>
                            </div>
                            <div class="profile-info-row">
                                <div class="profile-info-name">Xác nhận mật khẩu mới</div>
                                <div class="profile-info-value">
                                    @Html.PasswordFor(x => x.ConfirmPassword, new { @required = "required", error = "Mật khẩu không được rỗng" })
                                    @Html.ValidationMessageFor(x => x.ConfirmPassword)
                                </div>
                            </div>

                        </div>

                        <div class="space-20"></div>

                        <div class="center">
                            <input type="submit" class="btn btn-sm btn-primary" value="Save" onclick="return submitForm();" />
                        </div>

                    </div>
                }
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function submitForm() {
        var password = $('#Password').val();
        var confirmPassword = $('#ConfirmPassword').val();
        if (password != confirmPassword) {
            alertError("Xác nhận mật khẩu mới bị sai, vui lòng nhập lại");
            $('#ConfirmPassword').val('');
            $('#ConfirmPassword').focus();
            return false;
        }
        return true;
    }

    $(document).ready(function () {
        customValidate();
    });

    var message = '@ViewBag.Message';
    if (message == null || message == '') {
        $("#alert").removeClass();
        $("#alert").html('');
    }
    else {
        $("#alert").addClass("alert alert-block alert-success");
        $("#alert").html(message);
    }
</script>
